from math import gcd
for _ in range(int(input())):
n=int(input())
l=list(map(int,input().strip().split()))
l1=l[::2]
l2=l[1::2]
a,b=l1[0],l2[0]
if len(l1)>1:
for i in range(1,n//2+n%2):
a=gcd(l1[i],a)
if a==1:
break
if len(l2)>1:
for i in range(1,n//2):
b=gcd(l2[i],b)
if b==1:
break
if a>1:
for i in range(n//2):
if l2[i]%a==0:
a=1
break
if b>1:
for i in range(n//2+n%2):
if l1[i]%b==0:
b=1
break
if a==b:
print(0)
else:
print(max(a,b))
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
ll t;
cin >> t;
while (t--)
{
ll n;
cin >> n;
ll a[n];
for (ll i = 0; i < n; i++)
{
cin >> a[i];
}
bool flag = true;
ll var;ll x=0,y=0;bool ok=true;
for (ll i = 0; i < n; i++)
{
if(i%2==0){
x=__gcd(x,a[i]);
}
else{
y=__gcd(y,a[i]);
}
}
for(int i=0;i<n;i++){
if(i%2==0 && a[i]%y==0){
flag=false;
}
else if(i%2!=0 && a[i]%x==0){
ok=false;
}
}
if (flag == true)
{
cout <<y<< endl;
}
else if (ok == true)
{
cout <<x<< endl;
}
else
{
cout << 0 << endl;
}
}
return 0;
}
137. Single Number II | 130. Surrounded Regions |
129. Sum Root to Leaf Numbers | 120. Triangle |
102. Binary Tree Level Order Traversal | 96. Unique Binary Search Trees |
75. Sort Colors | 74. Search a 2D Matrix |
71. Simplify Path | 62. Unique Paths |
50. Pow(x, n) | 43. Multiply Strings |
34. Find First and Last Position of Element in Sorted Array | 33. Search in Rotated Sorted Array |
17. Letter Combinations of a Phone Number | 5. Longest Palindromic Substring |
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |